home *** CD-ROM | disk | FTP | other *** search
/ Aminet 25 / Aminet 25 (1998)(GTI - Schatztruhe)[!][Jun 1998].iso / Aminet / comm / misc / RecentScript.lha / RecentScript / Importers / OnlineSearch.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1998-03-15  |  2.3 KB  |  97 lines

  1. /*****
  2.   $VER: RecentScript Online Search Importer 1.0 (12.3.98) ©Arndt van der Molen
  3.  
  4.  
  5.     RecentScript Importer for online searching the AmiNet
  6.  
  7.   is a MUIRexx subapplication and can not be started directly.
  8.  
  9.   It is called only from RecentScript at the 'Import' button.
  10.  
  11.   This importer delivers the filename of a temporary file with
  12.   a maximum of 400 archives matching the search string. The search
  13.   string must be entered in the RecentScript GUI in the string gadget.
  14.  
  15.   Thanks:
  16.     Thanks to 'bossman^' for his AMSD tool which gives me the
  17.     inspiring idea for this importer.
  18.  
  19.   Known 'Bugs':
  20.    - Temporary file will not be deleted
  21. *****/
  22.  
  23. OPTIONS RESULTS
  24.  
  25. PARSE ARG portname
  26.  
  27. ADDRESS VALUE portname
  28.  
  29. MUIM_Busy_Move      = '0x80020001'
  30. MUIA_Busy_Speed     = '0x80020049'
  31. MUIV_Busy_Speed_Off =  0
  32.  
  33. maxfound            = 400
  34.  
  35.  
  36. /* Get search string from RecentScript string gadget */
  37. string ID STR_PATT
  38. pattern  = result
  39.  
  40.  
  41. IF pattern = "" THEN DO
  42.   request ID RECSCRWIN TITLE '"Importer Error"' GADGETS "_OK" STRING "You must enter a search string in RecentScript"
  43.   RETURN
  44. END
  45.  
  46. IF SHOWLIST(H,'TCP') THEN DO
  47.  
  48.   IF OPEN(writehandle, 'T:RS.temp', 'W') THEN DO
  49.  
  50.     window ID OSWIN TITLE '"AmiNet Online Search "' PORT portname
  51.       text ID OSTXT LABEL 'Connect to ftp.wustl.edu...'
  52.       object CLASS '"Busy.mcc"' ID OSBUSY
  53.     endwindow
  54.  
  55.     IF OPEN(tcphandle, 'TCP:ftp.wustl.edu/1848', 'W') THEN DO
  56.  
  57.       text ID OSTXT LABEL 'Search for "'pattern'"...'
  58.       object ID OSBUSY ATTRS MUIA_Busy_Speed MUIV_Busy_Speed_Off
  59.  
  60.       WRITECH(tcphandle, 'max 'maxfound' ; find 'pattern' ; quit' || '0a'x || '0d'x)
  61.  
  62.       text ID OSTXT LABEL 'Retrieve search result...'
  63.  
  64.       DO UNTIL EOF(tcphandle)
  65.  
  66.         method ID OSBUSY MUIM_Busy_Move
  67.  
  68.         line = READLN(tcphandle)
  69.  
  70.         IF LEFT(line,6)='*** No' then leave
  71.  
  72.         WRITELN(writehandle, line)
  73.       END
  74.  
  75.       CLOSE(tcphandle)
  76.       CLOSE(writehandle)
  77.       window ID OSWIN CLOSE
  78.  
  79.       RETURN "T:RS.temp"
  80.     END
  81.     ELSE DO
  82.       request ID RECSCRWIN TITLE '"Importer Error"' GADGETS "_OK" STRING "Cannot connect to 'ftp.wustl.edu'"
  83.     END
  84.  
  85.     window ID OSWIN CLOSE
  86.     CLOSE(writehandle)
  87.   END
  88.   ELSE DO
  89.     request ID RECSCRWIN TITLE '"Importer Error"' GADGETS "_OK" STRING "Cannot open temporary file"
  90.   END
  91. END
  92. ELSE DO
  93.   request ID RECSCRWIN TITLE '"Importer Error"' GADGETS "_OK" STRING "No TCP/IP found - You must be online!"
  94. END
  95.  
  96. RETURN
  97.